package com.example.friendfindertwo.data.helper;


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

public class CategoryDAO extends AbstractDAO{
	
//	private SQLiteDatabase database;
//	private DBHelper dbHelper;
	private Context context;
	
	public CategoryDAO(Context context){
		this.context = context;
	}
	
//	public void open() throws SQLException{
//		database = dbHelper.getWritableDatabase();
//	}
//	
//	public void close(){
//		dbHelper.close();
//	}
	
	public void createCategoryDummies(){
		AbstractDAO.open(context);
		createCategory("sport");
		createCategory("party");
		createCategory("eat");
		//AbstractDAO.close();
	}
	
	public String createCategory(String name){
		ContentValues values = new ContentValues();
		values.put(CategoryTable.COLUMN_NAME, name);
		long insertId = database.insert(CategoryTable.TABLE_CATEGORY, null, values);
		Cursor cursor = database.query(CategoryTable.TABLE_CATEGORY, null, CategoryTable.COLUMN_ID + " = " + insertId, null, null, null, null);
		cursor.moveToFirst();
		String cat = cursorToCategory(cursor);
		return cat;
	}
	
	private String cursorToCategory(Cursor cursor){
		return cursor.getString(0);	
	}
}
